package com.example.mongodb_demo.service.impl;

import com.example.mongodb_demo.doman.Dish;
import com.example.mongodb_demo.service.DishService;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DishServiceImpl implements DishService {

    @Resource
    private MongoTemplate mongoTemplate;

    @Override
    public Dish addDish(Dish dish) {
        return mongoTemplate.save(dish);
    }

    @Override
    public List<Dish> findDishAll() {
        return mongoTemplate.findAll(Dish.class);
    }
}
